<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <#include "../../common/header.ftl">

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/bootstrap-table.min.css">
    <!-- Latest compiled and minified JavaScript -->
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/bootstrap-table.min.js"></script>
    <!-- Latest compiled and minified Locales -->
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.12.1/locale/bootstrap-table-zh-CN.min.js"></script>
</head>
<body>
<div class="container-fluid">
    <#include "../../common/left-nav.ftl">

    <div class="main-box">
        <ol class="breadcrumb crumbs">
            <li><a href="#">企业管理</a></li>
        </ol>

        <div class="search-bar">
            <input type="text" placeholder="输入名称查询" id="searchBox">
            <a href="${base}/admin/company/edit" class="btn btn-default btn-in-input">
                <span class="glyphicon glyphicon-plus"></span>
            </a>
        </div>
        <div style="padding: 10px">
            <table id="table"></table>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript">
    $(document).ready(function () {
        $('#searchBox').keypress(function (event) {
            if (event.keyCode === 13) {
                console.info($(this).val());
            }
        });
        var dataTable = $('#table');
        dataTable.bootstrapTable({
            pagination: true,
            url: API_COMPANY + '/page',
            ajaxOptions: {
                headers: {
                    access_token: getToken()
                }
            },
            responseHandler: function (res) {
                return {
                    "total": res.total,
                    "rows": res.list
                };
            },
            sidePagination: 'server',
            columns: [
                {field: 'id', title: 'ID', visible: false},
                {
                    field: 'unitName', title: '名称', width: 200, formatter: function (value, row) {
                        return '<a href="' + ctx + '/admin/company/' + +row.id + '">' + value + '</a>';
                    }
                },
                {field: 'contact', title: '联系人', width: 150},
                {field: 'tel', title: '联系电话', width: 150},
                {field: 'address', title: '联系地址'}
            ]
        });
    })
</script>